package com.zp.qualitypractice.mvp3;

import java.util.List;

/**
 * Created by izp on 2017/6/1.
 */

public class MainPresenter implements MainContract.Presenter {
    private final AccountRepository mRepository;
    private final MainContract.View mView;

    public MainPresenter(AccountRepository repository, MainContract.View view) {
        mRepository = repository;
        mView = view;
        mView.setPresenter(this);
    }

    @Override
    public void start() {
    }

    @Override
    public void queryAccount(Object user, String startDate, String endDate, int page) {
        mRepository.queryDefBookAccounts(user, startDate, endDate, -1, page, false, new AccountDataSource.QueryAccountListCallback() {
            @Override
            public void querySuccess(List<Object> list) {
                mView.querySuccess(list);
            }

            @Override
            public void shareUsers(int count) {
                mView.shareUsers(count);
            }

            @Override
            public void queryFail(Error e) {
                mView.queryFail(e);
            }
        });
    }

    @Override
    public void queryAccountTotalMoney(Object user, String startDate, String endDate) {
        mRepository.queryDefBookTotalMoney(user, startDate, endDate, new AccountDataSource.QueryBookTotalMoneyCallback() {
            @Override
            public void querySuccess(double totalCost, double totalIncome) {
                mView.queryTotalMoneySuccess(totalCost, totalIncome);
            }

            @Override
            public void queryFail(Error e) {
                mView.queryTotalMoneyFail(e);
            }
        });
    }

    @Override
    public void deleteAccount(Object account) {
        mRepository.deleteAccount(account, new Object() {
//            @Override
//            public void requestSuccess() {
//                mView.deleteSuccess();
//            }
//
//            @Override
//            public void requestFail(Error e) {
//                mView.deleteFail(e);
//            }
        });
    }
}
